package com.xjh.basestudy.designmode.behaviorMode.behaviorMode4_Strategy.p2_strategy;

/**
 * @Author XuJianHua
 * @Date 2022/10/4 15:51
 * @Description

 */
public class Calculator {

    private Strategy strategy;//算法策略接口

    public void setStrategy(Strategy strategy) {//注入算法策略
        this.strategy = strategy;
    }

    public int getResult(int a, int b){
        return this.strategy.calculate(a, b);//返回具体策略的运算结果
    }
}